#include "../adapter/skyAdapter.h"
#ifdef WIN32
#include "../inc/skyPolicy.h"
#include "../inc/skyTimer.h"
namespace Sky
{

VOID  CALLBACK   adpTimerProc( HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime)
{
	Timer::myAdapData data = xGlobal<Timer::myAdapData>::get();
	data.proc(data.pUser);
	return;
}

TBool Timer::CreateTimer( TInt timerID,TimerProc proc,TInt span ,TVoid* pUser)
{
	if(mCreated)
		return vTrue;
	myAdapData data;
	data.proc = proc;
	data.pUser = pUser;

	xGlobal<Timer::myAdapData>::set(data);

	TInt i = ::SetTimer(vNull,1,span/1000,adpTimerProc);
	DWORD R = ::GetLastError();
	mTimerID = timerID;
	mCreated = vTrue; 
	return vTrue;
}

TVoid Timer::DeleteTimer( TInt timerID )
{
	if(mCreated == vFalse)
		return;

	KillTimer(vNull ,timerID);
	mCreated = vFalse;
	return;
}



Timer::~Timer()
{
	DeleteTimer(mTimerID);
}
}
#endif
